package test;

import java.lang.reflect.Field;
import java.lang.reflect.Modifier;

/**
 * @author zhu
 * @date 2024-03-26
 */
public class MainTest02 {
    public static void main(String[] args) throws Exception {
        Class<?> clazz = Integer.class;

        String strClassName = Modifier.toString(clazz.getModifiers());
        String className = clazz.getSimpleName();

        Field[] fields = clazz.getDeclaredFields();

        System.out.println(strClassName + " class " + className + " {");
        for (Field field : fields){
            String fieldName = field.getName();
            String fieldType = field.getType().getSimpleName();
            int intModifiers = field.getModifiers();
            String stringModifiers = Modifier.toString(intModifiers);

            System.out.println("    " + stringModifiers + " " + fieldType + " " + fieldName);
        }
        System.out.println("}");
    }
}
